﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FTradeReceivablesUpdateSaleType.aspx.cs"
    Inherits="IHISCETeim.Web.MachineSys.FTradeModel.FTradeReceivablesUpdateSaleType" %>

<%--改分期--%>
<script type="text/javascript">

    $(document).ready(function () {
        $("#FTradeReceivablesUpdateSaleTypeOld_Price,#FTradeReceivablesUpdateSaleTypeOld_GPSFeiYong,#FTradeReceivablesUpdateSaleTypeOld_YueCuXiaoJinE").change(function () {
            changeHHeTongJinE()
        })
        function changeHHeTongJinE() {
            //处理合同金额
            if ($(this).val() == "")
                $(this).val(0);
            var Price = parseFloat($("#FTradeReceivablesUpdateSaleTypeOld_Price").val());
            var GPSFeiYong = parseFloat($("#FTradeReceivablesUpdateSaleTypeOld_GPSFeiYong").val());
            var YueCuXiaoJinE = parseFloat($("#FTradeReceivablesUpdateSaleTypeOld_YueCuXiaoJinE").val());

            $("#FTradeReceivablesUpdateSaleTypeOld_HeTongJinE").val((-1) * Price + GPSFeiYong + YueCuXiaoJinE);
        }
        $("#FTradeReceivablesUpdateSaleTypeOld_GPSFeiYong").val((-1) * parseFloat($("#FTradeReceivablesUpdateSaleTypeOld_GPSFeiYong").val()));
        $("#FTradeReceivablesUpdateSaleTypeOld_YueCuXiaoJinE").val((-1) * parseFloat($("#FTradeReceivablesUpdateSaleTypeOld_YueCuXiaoJinE").val()))

        changeHHeTongJinE();

        //处理合同金额
        $("#FTradeReceivablesUpdateSaleType_Price,#FTradeReceivablesUpdateSaleType_GPSFeiYong,#FTradeReceivablesUpdateSaleType_YueCuXiaoJinE").change(function () {
            if ($(this).val() == "")
                $(this).val(0);
            var Price = parseFloat($("#FTradeReceivablesUpdateSaleType_Price").val());
            var GPSFeiYong = parseFloat($("#FTradeReceivablesUpdateSaleType_GPSFeiYong").val());
            var YueCuXiaoJinE = parseFloat($("#FTradeReceivablesUpdateSaleType_YueCuXiaoJinE").val());

            $("#FTradeReceivablesUpdateSaleType_HeTongJinE").val(Price + GPSFeiYong + YueCuXiaoJinE);

        })
    })

    function validateCallbackFTradeReceivablesUpdateSaleType(form, callback) {

        var $form = $(form);
        var $oldHeTongHao = "<%=obj.HeTongHao %>";
        var $newHeTongHao = $("#FTradeReceivablesUpdateSaleType_HeTongHao").val();
        //var $table = $form.find("tbody.ODailyAdd");
        var $newXiaoShouLeiXing = $("#FTradeReceivablesSaleTypeAdd_XiaoShouLeiXing").val();
        if ($newXiaoShouLeiXing == "请选择") {
            alertMsg.warn("请先选择一个 新的收款条款");
            return false;
        }
//        if ($oldHeTongHao == $newHeTongHao) {
//            alertMsg.warn("变更收款条款后，需要更改合同号");
//            $form.find("#FTradeReceivablesUpdateSaleType_HeTongHao").focus();
//            return false;
//        }
        //新增时需要处理 金额是否与合同金额一致
        var $XiaoShouLeiXing = $("#FTradeReceivablesSaleTypeUpdateSaleType_XiaoShouLeiXing").val();
        var $HeTongJinE = $("#FTradeReceivablesUpdateSaleType_HeTongJinE").val();
        var $inputPageJinE = 0;
        $("#FTradeReceivablesSaleTypeUpdateSaleType_ShowXXLSPage").find(":text[name='Page_JinE']").each(function () {
            $inputPageJinE = $inputPageJinE + parseFloat($(this).val());
        });
        if (parseFloat($HeTongJinE).toFixed(4) != parseFloat($inputPageJinE).toFixed(4)) {
            alertMsg.warn("合同金额与收款条款[" + $XiaoShouLeiXing + "]相应金额不一致,请检查更改后再提交.");
            return false;
        }
        //
        //alert(1);
        $("#FTradeReceivablesUpdateSaleType_BtnSave").find("button").attr("disabled", "disabled").html("改分期中......");
        setTimeout(function () { $("#FTradeReceivablesUpdateSaleType_BtnSave").find("button").removeAttr("disabled").html(" 改 分 期 "); }, 20000);
        
        return validateCallback(form, callback);
    }
</script>
<div class="pageContent">
    <form method="post" action="FTradeModel/FTradeReceivablesUpdateSaleType.aspx?ajaxmethod=edit&FTradeID=<%=FTradeID %>&OldFTradeSalesId=<%=obj.FTradeSalesId %>"
    class="pageForm required-validate" onsubmit="return validateCallbackFTradeReceivablesUpdateSaleType(this, navTabAjaxDone);">
    <div class="pageFormContent" layouth="56">
        <h2 style="clear: both; padding: 5px; border-bottom: 1px solid #B8D0D6; margin-bottom: 5px;">
            改分期说明:
        </h2>
        <div style="line-height: 23px; clear: both; padding: 5px; border: 1px solid #B8D0D6;
            margin-bottom: 5px;">
           1.可手动修改原合同的相应金额信息,系统将会以此信息为准,自动生成一条负记录.<br/>
           2.原合同已收将会自动等于原合同金额，未收及逾期将自动为0.<br/>
           3.如果有冲过帐,在改分期后将自动转到冲帐界面,可自行分配.<br/>
           4.<b style="color: Green; font-weight: bold;">改分期后 新的收款条款：</b>此信息务必填写.
        </div>
        <div style="clear: both; margin-bottom: 5px;">
        </div>
        <h2 style="padding: 5px 0px 5px 6px; border-bottom: 1px solid #B8D0D6;">
            一、改分期前合同信息 【<a href="FTradeModel/FTradeReceivablesView.aspx?FTradeID=<%=FTradeID %>"
                target="navTab" title="查看数据源" rel="FTradeReceivablesView" style="font-weight: normal!important;
                color: Red;">点击</a>】可查看原合同的详细信息</h2>
        <p>
            <label>
                合 同 号：</label>
            <input name="HeTongHao_Fu" type="text" id="FTradeReceivablesUpdateSaleTypeOld_HeTongHao" class="required"
                readonly value="<%=obj.HeTongHao %>" />
        </p>
        <p>
            <label>
                改分期时间：</label>
            <input name="XiaoShouShiJian_Fu" class="required date" type="text" value="" alt="" />
        </p>
        <p>
            <label>
                经 销 商：</label>
            <input name="JingXiaoShang_Fu" type="text" value="<%=obj.JingXiaoShang %>" class="required textInput "
                readonly />
        </p>
        <p>
            <label>
                营业经理：</label>
            <input name="YingYeJingLi_Fu" class="required" type="text" value="<%=obj.YingYeJingLi %>"
                alt="请输入营业经理" />
        </p>
        <div class="divider">
        </div>
        <p>
            <label>
                型 号：</label>
            <input name="XingHao_Fu" class="required" type="text" value="<%=obj.XingHao %>" readonly />
        </p>
        <p>
            <label>
                机 号：</label>
            <input name="JiHao_Fu" class="required" type="text" size="" alt="" value="<%=obj.JiHao %>"
                readonly />
        </p>
        <div class="divider">
        </div>
        <p>
            <label>
                单 价：</label>
            <input id="FTradeReceivablesUpdateSaleTypeOld_Price" name="Price_Fu" class="required inputFloat"
                type="text" value="<%=obj.Price %>" size="" alt="" />
            <span class="unit">元</span>
        </p>
        <p>
            <label>
                GPS费 用：</label>
            <input id="FTradeReceivablesUpdateSaleTypeOld_GPSFeiYong" name="GPSFeiYong_Fu" class="required inputFloat"
                type="text" value="<%=obj.GPSFeiYong %>" size="" alt="" />
            <span class="unit">元</span>
        </p>
        <p>
			<label>GPS 号：</label>
			<input name="" class="" type="text" value="<%=obj.GPSNum %>" size="" alt="" readonly/>
		</p>
        <p>
            <label>
                月促销折让金额：</label>
            <input id="FTradeReceivablesUpdateSaleTypeOld_YueCuXiaoJinE" name="YueCuXiaoJinE_Fu" class="required inputFloat"
                type="text" value="<%=obj.YueCuXiaoJinE %>" size="" alt="" />
            <span class="unit">元</span>
        </p>
        <p>
				        <label>利息收入：</label>
				        <input  name="InterestIncome_Fu" class="required inputFloat" type="text" value="<%=obj.InterestIncome %>" size="" alt="" readonly/>
                        <span class="unit">元</span>
			        </p>  
        <div class="divider"></div>
        <p>
            <label>
                合同金额：</label>
            <input id="FTradeReceivablesUpdateSaleTypeOld_HeTongJinE" name="HeTongJinE_Fu" class="required inputFloat"
                type="text" value="<%=obj.HeTongJinE %>" size="" alt="" />
            <span class="unit">元</span>
        </p>
         <p>
				<label>返还利息额：</label>
				<input  name="FanHuanLiXi_Fu" class="inputFloat" type="text" value="<%=obj.FanHuanLiXi %>"  readonly size="" alt=""/>
                <span class="unit">元</span>
			</p>   
        <p>
        <div style="clear: both;">
        </div>
        <label>
            合同付款条款：</label>
        <textarea name="FuKuanTiaoKuan_Fu" cols="80" rows="4"><%=obj.FuKuanTiaoKuan%></textarea>
        <div class="divider" style="clear: both; margin-bottom: 5px;"></div>
       
        <p>
			<label>已收款项：</label>
			<input name="YiShouKuanXiang" class="" type="text" readonly value="<%=obj.YiShouKuanXiang %>"　readonly />
		</p>
        <p>
			<label>未收款项：</label>
			<input name="WeiShouKuanXiang" class="" type="text" readonly value="<%=obj.WeiShouKuanXiang %>"　readonly />
		</p>
        <p>
			<label>逾期款项：</label>
			<input name="YuQiKuanXiang" class="" type="text" readonly value="<%=obj.YuQiKuanXiang %>"  alt=""/>
		</p>
       <div style="clear:both;margin-bottom: 5px;"></div>

        <h2 style="padding: 5px 0px 5px 6px; border-bottom: 1px solid #B8D0D6;">
            二.改分期后合同基本信息</h2>
        <p>
            <label>
                合 同 号：</label>
            <input name="HeTongHao" type="text" id="FTradeReceivablesUpdateSaleType_HeTongHao"
                class="required" value="<%=obj.HeTongHao %>" />
        </p>
        <p>
            <label>
                改分期后销售时间：</label>
            <input name="XiaoShouShiJian" class="required date" type="text" value=""  alt="" />
        </p>
        <p>
            <label>
                经 销 商：</label>
            <input name="JingXiaoShang" type="text" value="<%=obj.JingXiaoShang %>" class="required textInput autocomplete"
                autocompletehref="<%=AutoCompleteRequestUrl %>?ajaxmethod=getagentlist" swidth="300" />
        </p>
        <p>
            <label>
                营业经理：</label>
            <input name="YingYeJingLi" class="required" type="text" value="<%=obj.YingYeJingLi %>"
                alt="请输入营业经理" />
        </p>
        <div class="divider">
        </div>
        <p>
            <label>
                型 号：</label>
            <%=GetMacType("select", "XingHao", obj.XingHao)%>
        </p>
        <p>
            <label>
                机 号：</label>
            <input name="JiHao" class="required" type="text" size="" alt="" value="<%=obj.JiHao %>" />
        </p>
        <div class="divider">
        </div>
        <p>
            <label>
                单 价：</label>
            <input id="FTradeReceivablesUpdateSaleType_Price" name="Price" class="required inputFloat"
                type="text" value="<%=obj.Price %>" size="" alt="" />
            <span class="unit">元</span>
        </p>
        <p>
            <label>
                GPS费 用：</label>
            <input id="FTradeReceivablesUpdateSaleType_GPSFeiYong" name="GPSFeiYong" class="required inputFloat"
                type="text" value="<%=obj.GPSFeiYong %>" size="" alt="" />
            <span class="unit">元</span>
        </p>
        <p>
            <label>
                月促销折让金额：</label>
          
            <input id="FTradeReceivablesUpdateSaleType_YueCuXiaoJinE" name="YueCuXiaoJinE" class="required inputFloat"
                type="text" value="<%=obj.YueCuXiaoJinE %>" size="" alt="" />
            <span class="unit">元</span>
        </p>
          <p>
			<label>GPS 号：</label>
			<input name="GPSNum" class="" type="text" value="<%=obj.GPSNum %>" size="" alt="" readonly/>
		</p>
        <p>
				        <label>利息收入：</label>
				        <input  name="InterestIncome" class="required inputFloat" type="text" value="<%=obj.InterestIncome %>" size="" alt="" />
                        <span class="unit">元</span>
		</p>	        
        <div class="divider">
        </div>
        <p>
            <label>
                合同金额：</label>
            <input id="FTradeReceivablesUpdateSaleType_HeTongJinE" name="HeTongJinE" class="required inputFloat"
                type="text" value="<%=obj.HeTongJinE %>" size="" alt="" />
            <span class="unit">元</span>
        </p>
        <p>
				<label>返还利息额：</label>
				<input  name="FanHuanLiXi" class="inputFloat" type="text" value="<%=obj.FanHuanLiXi %>" size="" alt=""/>
                <span class="unit">元</span>
			</p>   
        <p>
        <p>
            <label>
                到期日：</label>
            <input name="DaoQiRi" class="" type="text" value="<%=obj.DaoQiRi %>" alt="" />
        </p>
        <div style="clear: both;">
        </div>
        <label>
            合同付款条款：</label>
        <textarea name="FuKuanTiaoKuan" cols="80" rows="4"><%=obj.FuKuanTiaoKuan%></textarea>
        <div class="divider" style="clear: both;"></div>
         

        <label style="color: Green; font-weight: bold;">
            改分期后 新的收款条款：</label>
        <select id="FTradeReceivablesSaleTypeUpdateSaleType_XiaoShouLeiXing" name="XiaoShouLeiXing" class="required">
            <%=GetXiaoShouLeiXing(obj.XiaoShouLeiXing)%>
        </select>
        <div id="FTradeReceivablesUpdateSaleType_ShowSummary" style=" line-height:30px; color:Red; font-weight:bold;" >
                       
        </div>
        <div style="clear: both;">
        </div>
        <div id="FTradeReceivablesSaleTypeUpdateSaleType_ShowXXLSPage" style="border: 1px dotted #B8D0D6;
            margin: 5px 0px;">
            <%--显示显示销售对应的配置--%>
        </div>
        <div style="color: Red; clear: both;"><%=canChange%></div>
        <script type="text/javascript">
            $(document).ready(function () {

                $("#FTradeReceivablesSaleTypeUpdateSaleType_XiaoShouLeiXing").change(function () {
                    changeXiaoShouLeiXingFTradeReceivablesSaleTypeUpdateSaleType($(this).val());
                })

                function changeXiaoShouLeiXingFTradeReceivablesSaleTypeUpdateSaleType(key) {
                   
                    //是否能更改
                    $.ajax({
                        type: 'get',
                        url: 'FTradeModel/FTradeReceivablesUpdateSaleType.aspx?ajaxmethod=canchange&oldLeiXing=' + encodeURI("<%=obj.XiaoShouLeiXing %>") + "&newLeiXing=" + encodeURI(key),
                        dataType: "text",
                        async: false,
                        cache: false,
                        success: function (json) {
                            try {
                                if (json == "true") {
                                    key = encodeURI(key);
                                    //2013-07-13
                                    var url = "FTradeModel/GetPageFTradeSaleTypeConfig.aspx?tag=updatesaletype&key=" + encodeURI(key)
                                    $("#FTradeReceivablesSaleTypeUpdateSaleType_ShowXXLSPage").loadUrl(url);
                                    //
                                    url = "FTradeModel/GetPageFTradeSaleTypeConfig.aspx?ajaxmethod=getconfigsummary&key=" + encodeURI(key)
                                    $("#FTradeReceivablesUpdateSaleType_ShowSummary").loadUrl(url);
                                }
                                else {
                                    $("#FTradeReceivablesSaleTypeUpdateSaleType_XiaoShouLeiXing").val("请选择");
                                    $("#FTradeReceivablesUpdateSaleType_ShowSummary").empty();
                                    alertMsg.warn('对不起,不能将[<%=obj.XiaoShouLeiXing %>]　变更成 [' + key + ']');
                                }
                            }
                            catch (e) {

                            }
                        }
                    });

                }

                changeXiaoShouLeiXingFTradeReceivablesSaleTypeUpdateSaleType("<%=obj.XiaoShouLeiXing %>"); 
            })
        </script>
        <div style="clear: both; margin-bottom: 5px;">
        </div>
    </div>
    <div class="formBar">
        <ul>
            <!--<li><a class="buttonActive" href="javascript:;"><span>保存</span></a></li>-->
            <li>
                <div class="buttonActive">
                    <div class="buttonContent" id="FTradeReceivablesUpdateSaleType_BtnSave">
                        <button type="submit">
                            改分期</button></div>
                </div>
            </li>
            <li>
                <div class="button">
                    <div class="buttonContent">
                        <button type="button" class="close">
                            取消</button></div>
                </div>
            </li>
        </ul>
    </div>
    </form>
</div>
